﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace BLL
{
    public class HanghoaBLL:DAL.HanghoaDAL
    {
        /// <summary>
        /// Kiểm tra insert
        /// </summary>
        /// <param name="Ma"></param>
        /// <returns></returns>
        public bool IsExists(string Ma)
        {
            var dt = base.Hanghoa_Select_Kiemtrama(Ma);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// Kiểm tra update
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="Ma"></param>
        /// <returns></returns>
        public bool IsExists(Guid Id, string Ma)
        {
            var dt = base.Hanghoa_Select_Kiemtrama(Ma);
            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["Id"].ToString() == Id.ToString())
                    {
                        return false;
                    }
                    else return true;
                }
            }
            return false;
        }
    }
}
